from socket import*
from multiprocessing import Process
from word_contoller import *

class WordPro(Process):
    def __init__(self,conn,addr):
        self.conn=conn
        self.addr=addr
        self.db=DictData()
        super().__init__()
    def run(self):
        while True:
            request=self.conn.recv(1024)
            tmp=request.decode().split("!9p@Yf0")
            if tmp[0]=="EXIT":
                break
        print("Connect Break",self.addr)
        self.conn.close()

class Run:
    def __init__(self):
        self.HOST="0.0.0.0"
        self.PORT=8888
        self.sock=self.get_connect()
    def get_connect(self):
        sock=socket()
        sock.bind((self.HOST,self.PORT))
        return sock
    def main(self):
        self.sock.listen(5)
        print("")
        while True:
            conn,addr=self.sock.accept()
            print("Connect",addr)
            self.wp=WordPro(conn,addr)
            self.wp.start()

if __name__ == '__main__':
    pro=Run()
    pro.main()